<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of UsersDAO
 *
 * @author gaurav
 */
class UsersDAO {

    public function getUsers(){

    } // to get all users
    public function getUserById($userId){

    } // to get user by id

    public function getUserByEmail($Email){

    } // to get user by UserName

    public function setUser($fName, $lName,  $password, $counrtyId, $stateId, $cityId, $email, $mobile){

                // to start logging on firebug tool
        ob_start();
        echo "in setuser";
        $connection =  DataBaseUtility::getConection();
        //  $sql = "SELECT ". Constant::$COL_ID. "," .Constant::$COL_STATE_ID .",".Constant::$COL_NAME." FROM ".Constant::$TABLE_CITY . "  where ".Constant::$COL_ID."= ".$cityId;
        $sql = "INSERT INTO ".Constant::$TABLE_USERS." (".Constant::$USERS_COL_FNAME. ", ".Constant::$USERS_COL_LNAME.", ". Constant::$USERS_COL_PASSWORD ." , " . Constant::$USERS_COL_EMAIL." , " . Constant::$USERS_COL_MOBILE. " , ". Constant::$USERS_COL_COUNTRY_ID ." , ". Constant::$USERS_COL_STATE_ID." , ".Constant::$USERS_COL_CITY_ID.") VALUES ( '".$fName."' , '".$lName."' , '".$password."' , '".$email."' , '".$mobile."' , '".$counrtyId."' , '".$stateId."' , '".$cityId."' );";
        echo "</br>".$sql;
        $result = mysql_query($sql);
        if(Constant::$APPICATION_MODE == "D") {
            FB::info("SQL --".$sql);

        }

        mysql_close($connection);
        return $result;
    } //to insert the user

    public function setUserById($userId, $fName, $lname, $password, $countryId, $stateId, $cityId, $email, $mobile){
        
    } // to update the user

    public function removeUsers(){
        
    } // to remove all users
    public function removeUserById( $userId){
        
    } // to remove user by Id

    public function removeUserByUserName( $userId){


    } // to remove user by Id
    public function checkUser( $email, $password){

        
    } // check username and password for login verification


    public function checkEmail($email){

     ob_start();

        $connection =  DataBaseUtility::getConection();
        $sql = "SELECT count(". Constant::$COL_ID. ") FROM ".Constant::$TABLE_USERS . "  where ".Constant::$USERS_COL_EMAIL."= \"".$email."\"";
        echo $sql."<br/>";
        $isuserExist = false;
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);
        $count = $row['id'];
        //echo "Row = ".count($row);
        if($count != 0){
            $isuserExist = true;
        }
        return $isuserExist;
    } //check email id already exist or not
}
?>
